package com.atguigu.demo.customer.service.impl;

import com.atguigu.demo.customer.bean.Customer;
import com.atguigu.demo.customer.mapper.CustomerMapper;
import com.atguigu.demo.customer.service.CustomerService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service("wang")    // 启动的时候组件会被创建（默认） 单态 一个java进程只有一个（默认）
@DS("mysql0411")
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper,Customer> implements CustomerService {

    @Autowired
    CustomerMapper customerMapper;
    @Override
    public void saveCustomer(Customer customer) {
        System.out.println("save:"+customer);
        customer.setName(customer.getName()+"_0301");
         customerMapper.insertCustomer(customer);  //0301
        customer.setName(customer.getName()+"_0212");
         customerMapper.insert(customer); // 0212

    }

    @Override
    public Customer getCustomerById(String id) {
        Customer customer = customerMapper.selectById(id);
        return customer;
    }
}
